package com.example.administrator.bleapp;

import android.app.Activity;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class RegisterActivity extends Activity {
//注册

    private TextView tv_baocun;
    private EditText ed_name,ed_phone;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        tv_baocun=findViewById(R.id.tv_baocun);
        ed_name=findViewById(R.id.ed_name);
        ed_phone=findViewById(R.id.ed_phone);
        tv_baocun.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //保存
                save(ed_name.getText().toString(),ed_phone.getText().toString());
            }
        });
    }
    private void save(String name,String phone){
        SharedPreferences sp=getSharedPreferences("user",MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("name",name);
        edit.putString("phone",phone);
        edit.commit();
    }
    private void getUser(){
        SharedPreferences sp = getSharedPreferences("user", 0);
        sp.getString("name", "");
        sp.getString("phone","");
    }
}
